home *** CD-ROM | disk | FTP | other *** search
- ; MOUSE ROUTINES
- ; Written by FRED SEXTON Jr.
- ; using MASM 6.0
- ; Hereby released to public domain
- ;
- OPTION EXPR16
- .MODEL MEDIUM
- hookmouse PROTO PASCAL ,mdat:PTR WORD
- unhookmouse PROTO PASCAL
- nu_tyme PROTO
- m_sub1 PROTO
- mreset PROTO PASCAL ,mok:PTR WORD
- mcuron PROTO PASCAL
- mcuroff PROTO PASCAL
- msetlim PROTO PASCAL ,minx:PTR WORD,maxx:PTR WORD,
- miny:PTR WORD,maxy:PTR WORD
- msetloc PROTO PASCAL ,sx:PTR WORD,sy:PTR WORD
- .DATA
- mdofs WORD ?
- tick BYTE 9
- oldintad WORD 2 dup(?)
-
- .CODE
- nu_tyme PROC uses ds si ;this is the routine that will
- mov si,seg tick ;be called by clock interrupt
- mov ds,si ;(18.2 times/second)
- dec tick ;interrupt 1CH is called by
- .IF zero? ;interrupt 08H
- mov tick,9
- mov si,mdofs
- mov word ptr ds:[si+2],0 ;every .5 sec set click counts
- mov word ptr ds:[si+6],0 ;to zero
- .ENDIF
- iret
- nu_tyme ENDP
-
- m_sub1 PROC uses ds ;this is the routine that will
- mov si,SEG mdofs ;be called by mouse activity
- mov ds,si
- mov si,mdofs
- mov ds:[si+8],cx ;mouse location
- mov ds:[si+10],dx
- mov ah,al
- and al,110y
- .if al == 2 ;left button press
- mov word ptr ds:[si],1
- mov word ptr ds:[si+6],0
- inc word ptr ds:[si+2]
- mov tick,9
- .elseif al == 4 ;left button release
- mov word ptr ds:[si],0
- .endif
- mov al,ah
- and al,11000y
- .if al == 8 ;right button press
- mov word ptr ds:[si+4],1
- mov word ptr ds:[si+2],0
- inc word ptr ds:[si+6]
- mov tick,9
- .elseif al == 16
- mov word ptr ds:[si+4],0 ;right button release
- .endif
- ret
- m_sub1 endp
-
- hookmouse PROC PASCAL uses ds es, mdat:PTR WORD
- mov bx,mdat
- mov mdofs,bx
- mov ax,SEG m_sub1 ;ES:DX points to user mouse
- mov es,ax ;event handler
- mov dx,OFFSET m_sub1
- mov ax,000CH
- mov cx,31 ;set user-defined mouse
- cli ;event handler
- int 33H
- sti
- mov ax,351CH ;get interrupt 1CH vector
- int 21h
- mov oldintad,bx ;save original address
- mov oldintad+2,es ;of user timer handler
- mov dx,OFFSET nu_tyme ;DS:DX points to new
- mov ax,SEG nu_tyme ;user timer handler
- mov ds,ax
- mov ax,251CH ;set interrupt 1CH vector
- cli
- int 21h
- sti
- ret
- hookmouse endp
-
- unhookmouse PROC PASCAL uses ds
- mov dx,oldintad ;DS:DX points to original
- mov ax,oldintad+2 ;user timer handler
- mov ds,ax
- mov ax, 251CH ;set interrupt 1CH vector
- cli
- int 21h
- xor ax,ax ;reset mouse
- int 33H
- sti
- ret
- unhookmouse ENDP
-
- mreset PROC PASCAL ,mok:PTR WORD
- xor ax,ax
- int 33H ;reset mouse
- mov bx,mok
- .if ax==0FFFFH
- mov word ptr [bx],1 ;mouse driver found
- .else
- mov word ptr [bx],0 ;mouse driver not found
- .endif
- ret
- mreset endp
-
- mcuron PROC PASCAL
- mov ax,1 ;turn on mouse cursor
- int 33H
- ret
- mcuron endp
-
- mcuroff PROC PASCAL
- mov ax,2 ;turn off mouse cursor
- int 33H
- ret
- mcuroff endp
-
- msetlim PROC PASCAL ,minx:PTR WORD,maxx:PTR WORD,
- miny:PTR WORD,maxy:PTR WORD
- mov bx,minx
- mov cx,[bx]
- mov bx,maxx
- mov dx,[bx]
- mov ax,7 ;set horizontal limit
- int 33H
- mov bx,miny
- mov cx,[bx]
- mov bx,maxy
- mov dx,[bx]
- mov ax,8 ;set vertical limit
- int 33H
- ret
- msetlim endp
-
- msetloc PROC PASCAL ,sx:PTR WORD,sy:PTR WORD
- mov si,mdofs
- mov bx,sx
- mov cx,[bx]
- mov ds:[si+8],cx ;set mx
- mov bx,sy
- mov dx,[bx]
- mov ds:[si+10],dx ;set my
- mov ax,4 ;set mouse location
- int 33H
- ret
- msetloc endp
-
- end
-